﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class FunctionBL
	{

		#region ***** Init Methods ***** 
		FunctionDA objFunctionDA;
		public FunctionBL()
		{
			objFunctionDA = new FunctionDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Function by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Function</returns>
		public Function GetByID(int id)
		{
			return objFunctionDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Function
		/// </summary>
		/// <returns>List<<Function>></returns>
		public List<Function> GetList()
		{
			string cacheName = "lstFunction";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objFunctionDA.GetList(), "Function");
			}
			return (List<Function>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Function
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsFunction";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objFunctionDA.GetDataSet(), "Function");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Function paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Function>></returns>
		public List<Function> GetListPaged(int recperpage, int pageindex)
		{
			return objFunctionDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Function paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objFunctionDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Function within Function database table
		/// </summary>
		/// <param name="obj_function">Function</param>
		/// <returns>key of table</returns>
		public int Add(Function obj_function)
		{
			ServerCache.Remove("Function", true);
			return objFunctionDA.Add(obj_function);
		}

		/// <summary>
		/// updates the specified Function
		/// </summary>
		/// <param name="obj_function">Function</param>
		/// <returns></returns>
		public void Update(Function obj_function)
		{
			ServerCache.Remove("Function", true);
			objFunctionDA.Update(obj_function);
		}

		/// <summary>
		/// Delete the specified Function
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Function", true);
			objFunctionDA.Delete(id);
		}
		#endregion
	}
}
